package com.lagou.session;

import com.lagou.pojo.Configuration;
import com.lagou.pojo.MapperStatement;

import java.beans.IntrospectionException;
import java.lang.reflect.InvocationTargetException;
import java.sql.SQLException;
import java.util.List;

/**
 * 执行器
 *
 * @author srh
 * @date 2020/02/22
 **/
public interface Executor {

    /**
     * 执行数据库操作
     *
     * @param configuration
     * @param mapperStatement
     * @param params
     * @param <T>
     * @return
     */
    <T> List<T> query(Configuration configuration, MapperStatement mapperStatement, Object... params) throws SQLException, IllegalAccessException, InstantiationException, IntrospectionException, InvocationTargetException, NoSuchFieldException;

    /**
     * 执行增删改
     *
     * @param configuration
     * @param mapperStatement
     * @param params
     * @return
     */
    int executor(Configuration configuration, MapperStatement mapperStatement, Object... params) throws SQLException, NoSuchFieldException, IllegalAccessException;

    /**
     * 释放资源
     */
    void close() throws SQLException;

    void commit() throws SQLException;
}
